package com.financing.wap.web.controller.api;

import java.util.List;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.annotation.Scope;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.stereotype.Controller;
import com.financing.wap.service.IFpFundBuynoticeService;
import com.financing.wap.common.Pager;
import com.financing.wap.common.ResultMap;
import com.financing.wap.common.ResultMap.STATUS;
import com.financing.wap.dto.FpFundBuynoticeDTO;
import com.financing.wap.web.controller.BaseController;

/**
 * @Description: Controller
 * @author caojiayao
 * @version 1.0
 * @created 
 */
@Controller
@RequestMapping("/api/fund")
@Scope("prototype")
public class FpFundBuynoticeAction  extends BaseController{
	@Autowired
	private IFpFundBuynoticeService fpFundBuynoticeService;
	
	@RequestMapping("/fdBuynoticeQueryList")
	@ResponseBody
	public ResultMap queryList(HttpServletRequest request,
			HttpServletResponse response,FpFundBuynoticeDTO dto,Pager pager) {
		ResultMap resultMap = new ResultMap();
		try{
			log.info("Begin query fa user list!");
			
			dto.setBegin(pager.getStartIndex());
			dto.setPageSize(pager.getPageSize());
			
			int count = fpFundBuynoticeService.countFpFundBuynotice(dto);
			pager.setTotalCount(count);
			List<FpFundBuynoticeDTO> list = fpFundBuynoticeService.listFpFundBuynotice(dto);
			
			resultMap.setAttribute("list",list);
			resultMap.setAttribute("pager", pager);
			resultMap.setStatus(STATUS.SUCCESS);
			resultMap.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
			
			log.info("End querylist!");
		}catch(Exception e){
			log.error("queryList error !",e);
			resultMap.setStatus(STATUS.FAILE);
			resultMap.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
		}
			
			
			return resultMap;
	}
	
	@RequestMapping("/fdBuynoticeDetail")
	@ResponseBody
	public ResultMap detail(HttpServletRequest request,
			HttpServletResponse response, FpFundBuynoticeDTO requestDto) {
		ResultMap resultMap = new ResultMap();
		try{
			FpFundBuynoticeDTO dto = fpFundBuynoticeService.getFpFundBuynotice(requestDto);
			
			resultMap.setAttribute("detail", dto);
			
			resultMap.setStatus(STATUS.SUCCESS);
			resultMap.setStatusCode(ResultMap.STATUS_CODE_SUCCESS);
		}catch(Exception e){
			log.error("query friendshipLink list error",e);
			resultMap.setStatus(STATUS.FAILE);
			resultMap.setStatusCode(ResultMap.STATUS_CODE_SYS_EXCEPTION);
		}
		
		return resultMap;

	}
}